# Maintainer: Stuart Cardall <developer@it-offshore.co.uk>
# Contributor: Bartłomiej Piotrowski <bpiotrowski@alpinelinux.org>
# Contributor: Pedro Filipe <xpecex@outlook.com>
pkgname=zram-init
pkgver=9.1
pkgrel=0
pkgdesc="wrapper script for the zram kernel module"
arch="noarch"
url="https://github.com/vaeth/zram-init"
license="GPL-2.0-only"
depends="e2fsprogs-extra util-linux" # we need zramctl from util-linux
subpackages="
	$pkgname-zsh-completion:zshcomp
	$pkgname-openrc
	$pkgname-doc
	"
source="$pkgname-$pkgver.tar.gz::https://github.com/vaeth/zram-init/archive/v$pkgver.tar.gz
	default-lz4.patch
	"
options="!check"

package() {
	install -Dm644 modprobe.d/zram.conf "$pkgdir"/lib/modprobe.d/zram.conf
	install -Dm755 sbin/zram-init "$pkgdir"/usr/sbin/zram-init

	install -Dm644 openrc/conf.d/zram-init "$pkgdir"/etc/conf.d/zram-init
	install -Dm755 openrc/init.d/zram-init "$pkgdir"/etc/init.d/zram-init

	install -Dm644 man/zram-init.8 -t "$pkgdir"/usr/share/man/man8
}

zshcomp() {
	depends=""
	pkgdesc="Zsh completions for $pkgname"
	install_if="$pkgname=$pkgver-r$pkgrel zsh"

	install -Dm644 "$builddir"/zsh/_zram-init -t "$subpkgdir"/usr/share/zsh/site-functions
}

sha512sums="4e3c76a389d188df98479f3f70af28405144b065df60ba191777cbec88d9bfe94be472d94bbb16314c0eefd41d177105cba74b45d1f13e82a741ff21a4d69c6a  zram-init-9.1.tar.gz
4dee4a83771fec0b4ea63e59f61d7615ae7253acaff46a219d700237326e8b96d3d2fda31754c3c7bc53c04159d163dcdc432bfb790f9e9a52faef508036b3ed  default-lz4.patch"
